3,846,550 members and growing!   9,974 now online. Dali Hammadi | My Settings | My Bookmarks | My Articles | Sign out
All Topics, C#, .NET >> C# Programming >> Unedited Reader Contributions  (Advanced)

Skin Recognition in C#
By xwml.

Skin Recognition in C#.
C#
Windows (Win2003, NT4, Win2K, WinXP, Win95, Win98, WinME), .NET
Win32, VS (VS.NET2002)
Dev
Posted: 29 Aug 2004
Views: 25,419
Note: This is an unedited reader contribution Modify | Delete 
Announcements


Search    
Advanced Search
Sitemap
Print Broken Article? Bookmark Discuss Send to a friend
22 votes for this article.
Popularity: 3.22. Rating: 2.4 out of 5.

Note: This is an unedited contribution. If this article is inappropriate, needs attention or copies someone else's work without reference then please Report this article.

Sample Image - Skin_RecC_.jpg

Introduction

     This article is based on a project I started this summer. Originally the project was a simple edge detection system, but now its turning into a face recognition system.

The first thing that I did done when implementing a skin filter is to convert from RGB color space

to IRgBy color space by using this formula:

I = [L(R) + L(B) + L(G)] / 3
Rg = L(R) - L(G)
By = L(B) - [L(G) +L(R)] / 2

where L is a logarithmic function.

The next thing is to find out the hue, by using this formula:
hue = atan2(Rg,By) * (180 / 3.141592654f)

if (I <= 5 && (hue >= 4 && hue <= 255))
{
     //skin
}
else
{
     /*not skin color it black*/
     modified.SetPixel(x, y, Color.Black);
}
 

 

An example of how you would call the method Vision.DetectSkin(Bitmap original, ref Bitmap modified)

Bitmap original = new Bitmap(@"C:\mypicture.bmp");
Bitmap modified = original;
Vision.DetectSkin(original, ref modified);
//now if you save modified and the look at it you will see that it 
//detected all the skin from the original image

As you can see from the picture the algorithm isn't perfect yet and it needs some touching up.

xwml


Click here to view xwml's online profile.


Other popular C# Programming articles:

[Top] Rate this Article for us!     PoorExcellent  
 
FAQ  Message score threshold    Search comments  
  View    Per page  
New Message Msgs 1 to 4 of 4 (Total: 4) (Refresh) First Prev Next     
Subject  Author  Date 
  recognition   amir mortazavi  5:34 27 Jan '05 
  I would have waited   Richard Parsons  17:51 30 Aug '04 
  References   Steven Campbell  16:43 30 Aug '04 
  Re: References   rajpatil  16:10 22 Sep '05 
Last Visit: 7:21 Sunday 3rd December, 2006 First Prev Next     

General comment    News / Info    Question    Answer    Joke / Game    Admin message


Updated: 29 Aug 2004 Article content copyright xwml, 2004
everything else Copyright © CodeProject, 1999-2007.
Web20 | Advertise on The Code Project | Privacy

The Ultimate Toolbox • ASP Alliance • Developer Fusion • Developersdex • DevGuru • Programmers Heaven • Planet Source Code • Tek-Tips Forums •